<template>
    <div class="login-log-list">
        <el-card shadow="hover">
            <div slot="header" class="head-title">
                <span>系统设置</span>
            </div>
            <div>
                <el-form ref="form" :model="form" label-width="120px">
                    <el-form-item :label="item.sysKey" v-for="item, index in sysConfigList" :key="index">
                        <el-input v-model="item.sysValue">
                            <template slot="append">单位：b，转换后为:{{ $global.getSize(parseInt(item.sysValue)) }}</template>
                        </el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="save">保存</el-button>
                        <el-button>取消</el-button>
                    </el-form-item>
                </el-form>
            </div>
        </el-card>
    </div>
</template>

<script>
export default {
    name: "setting",
    data() {
        return {
            form: {}
        }
    },
    mounted() {
        this.getSysConfigList()
    },
    methods: {
        async getSysConfigList() {
            let res = await this.$store.dispatch('getSysConfigList')
            if (!res.success) this.$global.resError(res)
        },
        async save() {
            let res = await this.$store.dispatch("updateSysConfig", this.sysConfigList)
            if(res.success){
                this.$message.success(res.message)
                this.getSysConfigList()
            }
            else this.$global.resError(res)
            
        }
    },
    computed: {
        sysConfigList() {
            return this.$store.state.sys.sysConfigList || []
        }
    }
}
</script>

<style scoped>
.head-title {
    font-size: 17px;
    font-weight: 550;
}
</style>